#include "contact.h"

int main()
{
	//con contact = { .arr = { 0 }, .sz = 0 };
	con contact = { .arr = NULL, .sz = 0, .capa = 0 };
	//Init(&contact);
	Load(&contact);
	while (1)
	{
		//Init(&contact);
		Menu();
		printf("\033[33mSelect an option.\033[0m\n");
		Options op = 0;
		scanf("%d", &op);
		while (getchar() != '\n');
		switch (op)
		{
		case EXIT:
		{
			Save(&contact);
			contact.arr = realloc(contact.arr, 0);
			contact.sz = 0;
			contact.capa = 0;
			printf("\033[32mSuccessfully exited.\033[0m\n");
			return 0;
		}
		case ADD:
		{
			Add(&contact);
			break;
		}
		case DELETE:
		{
			Delete(&contact);
			break;
		}
		case SEARCH:
		{
			Search(&contact);
			break;
		}
		case MODIFY:
		{
			Modify(&contact);
			break;
		}
		case SORT:
		{
			Sort(&contact);
			break;
		}
		case DISPLAY:
		{
			Display(&contact);
			break;
		}
		default:
		{
			printf("\033[31mTyping error.\033[0m\n");
			continue;
			break;
		}
		}
	}

	return 0;
}